package com.qingcloud.fexecutor.base.enums;

/**
 * 部署中心节点使用范围枚举.
 */
public enum DeployNodeTypeEnum {

    SERVICE(1, "服务节点"),
    SOFTWARE(2, "标准软件"),
    COMPUTER(3, "部署主机"),
    STORAGE(4, "数据存储"),
    OUT_SERVICE(5, "外部服务");

    public final Integer code;
    public final String name;

    DeployNodeTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        for (DeployNodeTypeEnum type : DeployNodeTypeEnum.values()) {
            if (code.equals(type.code)) {
                return type.name;
            }
        }
        return "";
    }

    public static DeployNodeTypeEnum findByName(String name) {
        for (DeployNodeTypeEnum type : DeployNodeTypeEnum.values()) {
            if (type.name().equalsIgnoreCase(name)) {
                return type;
            }
        }
        return null;
    }

}
